/**
 * Books路由模块
 */

var express = require('express');
var router = express.Router();

// 导入所需控制器
const { fetchFromDouban } = require("../controller/fetch");
const book = require("../controller/book");
const auth = require("../controller/auth");

// 定义路由
// 守卫路由：所有路由必须执行权限控制的判断
router.all("*", auth.isLogin);

// TODO:增加新的功能，及增加对应的路由、控制器以及访问数据库的数据模型
router.get("/fetch/douban/:isbn", fetchFromDouban);

router.get("/isbn/:isbn", book.findByIsbn);

router.get("/search", book.search);

router.get("/count",book.getCount)

router.get("/:id", book.find);

router.get("/", book.findAll);

router.post("/", book.add);

router.put("/:id", book.update);

router.delete("/:id", book.remove);

module.exports = router;